//
//  FavWorkCollectionViewCell.m
//  WULIHH
//
//  Created by chen tang on 16/4/27.
//  Copyright © 2016年 tang. All rights reserved.
//

#import "FavWorkCollectionViewCell.h"
#import "Header.h"
#import "UIImageView+WebCache.h"
#import "UIImage+WebP.h"

@interface FavWorkCollectionViewCell ()
{
    UIImageView *workImageView;
    UILabel *titleLable;
    UILabel *countLable;
    UIImageView *GoodImageView;
}

@end


@implementation FavWorkCollectionViewCell


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self initUI];
    }
    return self;
}

- (void)initUI
{
    UIImage *image = nil;
    workImageView = [[UIImageView alloc] initWithFrame:self.bounds];
    [workImageView.layer setMasksToBounds:YES];
    [workImageView setContentMode:UIViewContentModeScaleAspectFill];
    [self addSubview:workImageView];
    
    titleLable = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, 54.0)];
    [titleLable setNumberOfLines:2.0];
    [titleLable setFont:[UIFont systemFontOfSize:14.0]];
    [titleLable setBackgroundColor:[UIColor whiteColor]];
    [self addSubview:titleLable];
    
    
    UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, self.bounds.size.height-39.0, self.bounds.size.width, 39.0)];
    [self addSubview:bottomView];
    [bottomView setBackgroundColor:[UIColor whiteColor]];
    
    image = [UIImage imageNamed:@"good.png"];
    GoodImageView = [[UIImageView alloc] initWithFrame:CGRectMake(52, 12, image.size.width, image.size.height)];
    [GoodImageView setImage:image];
    [bottomView addSubview:GoodImageView];
    
    countLable = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(GoodImageView.frame)+5, 10, 100, 20)];
    [countLable setTextAlignment:NSTextAlignmentLeft];
    [countLable setFont:[UIFont systemFontOfSize:12.0]];
    [bottomView addSubview:countLable];
}



- (void)loadModel:(NSDictionary *)dic
{
    NSLog(@"%@", dic);
    [workImageView sd_setImageWithURL:[NSURL URLWithString:[dic valueForKey:@"imageUrl"]]];
    [titleLable setText:[dic valueForKey:@"title"]];
    [countLable setText:[NSString stringWithFormat:@"%@", [dic valueForKey:@"likeCount"]]];
}

@end
